function [CRLB,mat] = T2CramerRao(DT, echoesmdf, sigma)

% Computes the Cramer Rao Lower bound on the variance of the estimated parameters
% from measurements with echoesmdf as inversion times set.
% sigma: default = 1; Specifies the noise standard deviation of the
% images (sigma in the rice distribution), the resulting CRLB depends on the noise level. 
%
% Created by Henk Smit, EMC, 01-2011 based on the work by Dirk Poot, University of Antwerp, 13-8-2007.

if nargin<3
    sigma = 1;
end;

% DT(1,:) = DT(1,:)./sigma;

numtr = size(DT,2);
CRLB = zeros(size(DT,1),size(DT,1),numtr);
mat = zeros(2);

[A,dAdpar] = T2Magnitude(DT,echoesmdf);

if ~isequal(sigma,1)
    A = bsxfun(@times, A, 1./sigma);
end;

expectIA = rice_information_ExpectVal(A);

if ~isequal(sigma,1)
    expectIA = bsxfun(@times, expectIA , 1./ sigma.^2);
end;

for k=1:numtr
    FIM = (dAdpar(:,:,k)'*(dAdpar(:,:,k).*expectIA(:,k*ones(1,2)))); %HENK Fisher Information Matrix
    ws = warning('off');
    mat = inv(FIM);
    warning(ws);
%     mat(:,1) = mat(:,1)*sigma;
%     mat(1,:) = mat(1,:)*sigma;
    CRLB(:,:,k) = mat;
end;
